var t,
  a = require("../../@babel/runtime/helpers/defineProperty"),
  n = require("../../res/www.a9a.cn.js"),
  i = getApp();
Page({
  data: {
    topbar: ["活动介绍", "现场签到", "活动交流"],
    currentTab: 0,
    setInter: "",
    mask_class: "alpha0_100",
    div_hn_btm_box_class: "div_upAnm1",
  },
  onLoad: function (t) {
    var a = this;
    if (n.ifint(t.fid)) var o = t.fid;
    else {
      var e = decodeURIComponent(t.scene);
      o = (e = e.split("="))[1];
    }
    this.setData({ fid: o }),
      i.get_config("_ZEAI").then(function (t) {
        a.setData({ color: i._ZEAI.color, rgbcolor: n.c16_rgb(i._ZEAI.color) });
      }),
      i.get_navigationBarTopHeight(this),
      i.get_openid().then(function (t) {
        a.init();
      });
  },
  bannerFn: function (t) {
    if (!n.empty(this.data.banner)) {
      var a = t.currentTarget.dataset.cur;
      n.empty(a) || wx.previewImage({ current: a, urls: this.data.banner });
    }
  },
  init: function () {
    var a = this;
    n.ifint(this.data.fid) ||
      wx.showModal({
        content: "参数跑路了",
        confirmColor: a.data.color,
        confirmText: "朕知道了",
        showCancel: !1,
        success: function (t) {
          wx.navigateBack();
        },
      }),
      wx.showLoading({ title: "玩命加载中...", mask: !0 }),
      (t = wx.getStorageSync("COOK_U")),
      i.ajax({
        url: "party.php",
        data: { submitok: "party_detail", openid: t.openid, fid: a.data.fid },
        success: function (t) {
          if (1 == t.flag) {
            var i = t.D.plist,
              o = n.escape2Html(t.D.content);
            a.setData({
              D: t.D,
              BM: t.BM,
              DJS: t.DJS,
              banner: i,
              signnum: t.D.signnum,
              bbsnum: t.D.bbsnum,
              content: o,
              ios_ifpay: t.ios_ifpay,
            }),
              1 == t.DJS.flag && a.DJSFn(t.DJS.difftime);
          } else wx.showToast({ title: t.msg, icon: "none", mask: !0 });
          wx.hideLoading();
        },
      });
  },
  bm_addFn: function () {
    var a = this;
    i.ajax({
      url: "party.php",
      data: { submitok: "bm_add", openid: t.openid, fid: a.data.fid },
      success: function (o) {
        1 == o.flag
          ? a.setData({ div_bm_add: !0, U: o.U })
          : "pay" == o.flag
          ? 1 == o.ifpay &&
            wx.showModal({
              title: "",
              content: o.msg,
              confirmColor: a.data.color,
              cancelText: "取消",
              confirmText: "立即支付",
              success: function (o) {
                o.confirm &&
                  (1 != a.data.ios_ifpay.flag
                    ? wx.getSystemInfo({
                        success: function (o) {
                          "ios" == o.platform
                            ? wx.showModal({
                                title: "温馨提示",
                                content: a.data.ios_ifpay.tips,
                                confirmColor: a.data.color,
                                cancelText: "返回",
                                confirmText: "联系服务人员",
                                success: function (t) {
                                  t.confirm
                                    ? wx.redirectTo({ url: "../my/hongniang" })
                                    : t.cancel && wx.navigateBack();
                                },
                              })
                            : i.pay({
                                data: {
                                  submitok: "party_bm",
                                  openid: t.openid,
                                  fid: a.data.fid,
                                },
                                success: function () {
                                  a.init();
                                },
                                fail: function (t) {
                                  (t.this = a), (t.url = "no"), n.sorry(t);
                                },
                              });
                        },
                      })
                    : i.pay({
                        data: {
                          submitok: "party_bm",
                          openid: t.openid,
                          fid: a.data.fid,
                        },
                        success: function () {
                          a.init();
                        },
                        fail: function (t) {
                          (t.this = a), (t.url = "no"), n.sorry(t);
                        },
                      }));
              },
            })
          : ((o.this = a), (o.url = "no"), n.sorry(o));
      },
    });
  },
  div_bm_add_submitFn: function (a) {
    var o = this,
      e = a.detail.value;
    i.empty(e.sex)
      ? wx.showToast({ title: "请选择【性别】", icon: "none", mask: !0 })
      : i.ifmob(e.mob)
      ? i.ifweixin(e.weixin)
        ? i.empty(e.truename)
          ? wx.showToast({ title: "请输入【姓名】", icon: "none", mask: !0 })
          : !i.empty(e.birthday) && n.ifint(e.birthday)
          ? wx.showModal({
              title: "",
              content: "确定信息无误提交报名么？",
              confirmColor: o.data.color,
              cancelText: "取消",
              confirmText: "确定",
              success: function (a) {
                a.confirm &&
                  (wx.showLoading({ title: "正在提交", mask: !0 }),
                  i.ajax({
                    url: "party.php",
                    data: {
                      submitok: "bm_add_update",
                      openid: t.openid,
                      fid: o.data.fid,
                      sex: e.sex,
                      weixin: e.weixin,
                      mob: e.mob,
                      truename: e.truename,
                      birthday: e.birthday,
                    },
                    success: function (a) {
                      wx.hideLoading(),
                        1 == a.flag
                          ? wx.showModal({
                              content: a.msg,
                              confirmColor: o.data.color,
                              confirmText: "朕知道了",
                              showCancel: !1,
                              success: function (e) {
                                o.setData({ div_bm_add: !1 }),
                                  1 == a.ifpay
                                    ? wx.showModal({
                                        title: "",
                                        content: a.ifpay_str,
                                        confirmColor: o.data.color,
                                        cancelText: "稍后支付",
                                        confirmText: "立即支付",
                                        success: function (a) {
                                          a.confirm
                                            ? 1 != o.data.ios_ifpay.flag
                                              ? wx.getSystemInfo({
                                                  success: function (a) {
                                                    "ios" == a.platform
                                                      ? wx.showModal({
                                                          title: "温馨提示",
                                                          content:
                                                            o.data.ios_ifpay
                                                              .tips,
                                                          confirmColor:
                                                            o.data.color,
                                                          cancelText: "返回",
                                                          confirmText:
                                                            "联系服务人员",
                                                          success: function (
                                                            t
                                                          ) {
                                                            t.confirm
                                                              ? wx.redirectTo({
                                                                  url: "../my/hongniang",
                                                                })
                                                              : t.cancel &&
                                                                wx.navigateBack();
                                                          },
                                                        })
                                                      : i.pay({
                                                          data: {
                                                            submitok:
                                                              "party_bm",
                                                            openid: t.openid,
                                                            fid: o.data.fid,
                                                          },
                                                          success: function () {
                                                            o.init();
                                                          },
                                                          fail: function (t) {
                                                            (t.this = o),
                                                              (t.url = "no"),
                                                              n.sorry(t);
                                                          },
                                                        });
                                                  },
                                                })
                                              : i.pay({
                                                  data: {
                                                    submitok: "party_bm",
                                                    openid: t.openid,
                                                    fid: o.data.fid,
                                                  },
                                                  success: function () {
                                                    o.init();
                                                  },
                                                  fail: function (t) {
                                                    (t.this = o),
                                                      (t.url = "no"),
                                                      n.sorry(t);
                                                  },
                                                })
                                            : o.init();
                                        },
                                      })
                                    : o.init();
                              },
                            })
                          : ((a.this = o), (a.url = "no"), n.sorry(a));
                    },
                  }));
              },
            })
          : wx.showToast({ title: "请输入【生年】", icon: "none", mask: !0 })
        : wx.showToast({ title: "请输入【微信】", icon: "none", mask: !0 })
      : wx.showToast({ title: "请输入【手机】", icon: "none", mask: !0 });
  },
  vipFn: function () {
    i.chklogin().then(function (t) {
      t
        ? wx.navigateTo({ url: "../my_vip/my_vip" })
        : wx.navigateTo({ url: "../login/login" });
    });
  },
  mask_closeFn: function (t) {
    var n = this,
      i = t.currentTarget.dataset.maskid;
    this.setData({ mask_class: "alpha100_0" }),
      setTimeout(function () {
        var t;
        n.setData((a((t = {}), i, !1), a(t, "mask_class", "alpha0_100"), t));
      }, 500);
  },
  DJSFn: function (t) {
    var a = this;
    a.data.setInter = setInterval(function () {
      var n = 0,
        i = 0,
        o = 0,
        e = 0;
      t > 0
        ? ((n = Math.floor(t / 86400)),
          (i = Math.floor((t / 3600) % 24)) <= 9 && (i = "0" + i),
          (o = Math.floor((t / 60) % 60)) <= 9 && (o = "0" + o),
          (e = Math.floor(t % 60)) <= 9 && (e = "0" + e),
          a.setData({ djs_D: n, djs_H: i, djs_M: o, djs_S: e }),
          t--)
        : (clearInterval(a.data.setInter), a.init());
    }, 1e3);
  },
  mapFn: function () {
    var t = this.b_t(this.data.D.longitude, this.data.D.latitude),
      a = parseFloat(t[0]),
      n = parseFloat(t[1]);
    wx.openLocation({
      latitude: Number(n),
      longitude: Number(a),
      scale: 14,
      name: this.data.D.address,
      address: this.data.D.address,
    });
  },
  b_t: function (t, a) {
    if (null == t || "" == t || null == a || "" == a) return [t, a];
    var n = 3.141592653589793,
      i = parseFloat(t) - 0.0065,
      o = parseFloat(a) - 0.006,
      e = Math.sqrt(i * i + o * o) - 2e-5 * Math.sin(o * n),
      s = Math.atan2(o, i) - 3e-6 * Math.cos(i * n);
    return [
      (t = (e * Math.cos(s)).toFixed(7)),
      (a = (e * Math.sin(s)).toFixed(7)),
    ];
  },
  topbarFn: function (a) {
    var n = this,
      o = 2 == a ? 2 : parseInt(a.currentTarget.dataset.idx);
    if ((this.setData({ currentTab: o }), 1 == o)) var e = "sign_ulist";
    else if (2 == o) e = "bbs_list";
    (1 != o && 2 != o) ||
      (wx.showLoading({ title: "玩命加载中...", mask: !0 }),
      i.ajax({
        url: "party.php",
        data: { submitok: e, openid: t.openid, fid: n.data.fid },
        success: function (t) {
          1 == t.flag
            ? 1 == o
              ? n.setData({ signnum: t.signnum, signulist: t.ulist })
              : 2 == o && n.setData({ bbsnum: t.bbsnum, bbslist: t.list })
            : wx.showToast({ title: t.msg, icon: "none", mask: !0 }),
            wx.hideLoading();
        },
      }));
  },
  bbs_btnFn: function () {
    var t = this;
    i.chklogin().then(function (a) {
      a ? t.setData({ div_bbs: !0 }) : wx.navigateTo({ url: "../login/login" });
    });
  },
  getPhoneNumber: function (t) {
    i.getPhoneNumber({
      e: t,
      url: "/pages/party/party_detail?fid=" + this.data.fid,
    });
  },
  getmobFn: function (n) {
    var o = this;
    wx.login({
      success: function (e) {
        wx.request({
          url: i.WWW + "/api/wxxcx/get_openid.php",
          data: { code: e.code },
          success: function (e) {
            (e = i.jsoneval(e.data)),
              (t = wx.getStorageSync("COOK_U")),
              wx.request({
                url: i.WWW + "/api/wxxcx/get_mob.php",
                data: {
                  session_key: encodeURIComponent(e.U.session_key),
                  encryptedData: encodeURIComponent(n.detail.encryptedData),
                  iv: encodeURIComponent(n.detail.iv),
                  openid: e.U.openid,
                  submitok: "getmob",
                },
                success: function (t) {
                  (t = i.jsoneval(t.data)),
                    o.setData(a({}, "U.cook_mob", t.mob));
                },
                fail: function (t) {
                  wx.showModal({ content: t, showCancel: !1 });
                },
              });
          },
        });
      },
    });
  },
  back: function () {
    this.setData({ div_login: !1 });
  },
  div_bbs_closeFn: function () {
    this.setData({ div_bbs: !1, div_bm_add: !1 });
  },
  div_bbs_submitFn: function (a) {
    var o = this,
      e = a.detail.value;
    i.empty(e.content)
      ? wx.showToast({ title: "请输入评论内容", icon: "none", mask: !0 })
      : wx.showModal({
          title: "",
          content:
            "确定提交么？\r\n以下情形话题将被删除或封号：\r\n《请勿留下任何形式联系方法》\r\n《请勿发表涉黄涉政言论》\r\n《不得辱骂或攻击他人》",
          confirmColor: o.data.color,
          cancelText: "取消",
          confirmText: "确定",
          success: function (a) {
            a.confirm &&
              (wx.showLoading({ title: "正在保存", mask: !0 }),
              i.ajax({
                url: "party.php",
                data: {
                  submitok: "bbs_add",
                  openid: t.openid,
                  fid: o.data.fid,
                  content: e.content,
                },
                success: function (t) {
                  wx.hideLoading(),
                    1 == t.flag
                      ? wx.showModal({
                          content: t.msg,
                          confirmColor: o.data.color,
                          confirmText: "朕知道了",
                          showCancel: !1,
                          success: function (t) {
                            o.setData({ div_bbs: !1 }), o.topbarFn(2);
                          },
                        })
                      : ((t.this = o), (t.url = "no"), n.sorry(t));
                },
              }));
          },
        });
  },
  onPageScroll: function (t) {
    t.scrollTop > 100
      ? this.setData({ backtop_flag: !0 })
      : this.setData({ backtop_flag: !1 });
  },
  backtopFn: function (t) {
    wx.pageScrollTo({ scrollTop: 0, duration: 300 });
  },
  zxFn: function () {
    wx.pageScrollTo({ scrollTop: 999999, duration: 300 });
  },
  telFn: function (t) {
    wx.makePhoneCall({ phoneNumber: this.data.D.kf_tel });
  },
  mobFn: function (t) {
    wx.makePhoneCall({ phoneNumber: this.data.D.kf_mob });
  },
  onShareAppMessage: function () {
    return {
      imageUrl: this.data.D.path_b,
      title: this.data.D.wxshareC,
      path: "/pages/party/party_detail?fid=" + this.data.fid,
    };
  },
  onShareTimeline: function () {
    var t;
    return (
      (t = {
        imageUrl: this.data.D.path_b,
        title: this.data.D.wxshareC,
        query: "",
      }),
      a(t, "query", "fid=" + this.data.fid),
      a(t, "path", "/pages/party/party_detail"),
      t
    );
  },
  ifagreeFn: function (t) {
    1 == t.detail.value
      ? this.setData({ ifagree: !0 })
      : this.setData({ ifagree: !1 });
  },
  ifagree_passFn: function () {
    wx.showToast({
      title: "请先点击同意《用户协议》和《隐私条款》",
      icon: "none",
      mask: !0,
      duration: 3e3,
    });
  },
});
